/**
 * \* Created with IntelliJ IDEA.
 * \* User: Administrator
 * \* Date: 2021/12/24
 * \* Time: 15:10
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class TestDemo {


    public static void main(String[] args) {
        String str = "hello world hello bit" ;
        String[] result = str.split(" ",2) ;
        for(String s: result) {
            System.out.println(s);
        }

        System.out.println("=======================");
        String str1 = "hello world hello bit" ;
        String[] result1 = str1.split(" ") ; // 按照空格拆分
        for(String s: result1) {
            System.out.println(s);
        }
    }
    public static void main1(String[] args) {
        String str = "helloworld" ;
// 将字符串变为字符数组
        char[] data = str.toCharArray() ;
        for (int i = 0; i < data.length; i++) {
            System.out.print(data[i]+" ");
        }
// 字符数组转为字符串
        System.out.println();
        System.out.println(new String(data)); // 全部转换
        System.out.println(new String(data,5,5)); // 部分转换
    }
}
